package com.situ.vivamarket.model.search;


import com.situ.vivamarket.model.Order;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Getter
@Setter
public class OrderSearchBean extends Order {
    private String account;//会员账号
    private String orderTime;//下单的时间区间
    private LocalDateTime orderTimeFrom;//开始
    private LocalDateTime orderTimeTo;//结束

    public void setOrderTime(String orderTime) {
        this.orderTime = orderTime;
        if(StringUtils.hasText(orderTime)){
            String[] arr = orderTime.split("\\s*~\\s*");
            this.orderTimeFrom = LocalDateTime.parse(arr[0], DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
            this.orderTimeTo = LocalDateTime.parse(arr[1], DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        }
    }
}
